function ajax({ type = "GET", url = "", data = "", dataType = "json" }) {
    url = `http://www.ujiuye.tech:3000/api${url}`;
    const p = new Promise((resolve, reject) => {
        $.ajax({
            type,
            url,
            dataType,
            data,
            success: function (rst) {
                let { code, result } = rst;//获取服务器结果
                if (code == 200) {
                    resolve(result);
                } else {
                    alert('请求失败');
                }
            },
            error: reject
        });
    });
    return p;
}


function to(p) {
    return p.then(rst => [null, rst]).catch(err => [err, null]);
}